<template>
    <div class="orderVue">
        <div class="order" v-for="(item, index) in list" :key="index">
            <div class="orderTop">
                <span class="oNo">售后编号: {{ item.refundOrderNo }}</span>
                <span class="state"> {{ statusArr[item.refundStatus] }}</span>
            </div>
            <div class="orderBot">
                <div class="infoVue" v-if="item.detail">
                    <img :src="item.detail.image" style="width: 50px; height: 50px; margin-right: 20px;">
                    <div class="right">
                        <div class="flex-between">
                            <div class="name line-1">{{ item.detail.productName }}</div>
                            <span style="color: #4D4D4D;">¥{{ item.detail.price }}</span>
                        </div>
                        <div class="flex-between">
                            <div style="color: #A1A2A1; font-size: 14px;">{{ item.detail.sku }}</div>
                            <span style="color: #4D4D4D;">×{{ item.detail.payNum }}</span>
                        </div>
                    </div>
                </div>
                <div class="cell">申请时间: {{ item.createTime }}</div>
                <div class="cell">申请退款: {{ item.refundPrice }}</div>
                <div class="opraVue">
                    <span @click="toDetail(item.refundOrderNo)">售后详情</span>
                    <div class="line"></div>
                    <span @click.stop="sendSold(item.refundOrderNo)">发送</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import { orderListAssistantApi } from '@/api/order';
    export default{
        props: {
            userId: {
                type: Number,
                default: ""
            }
        },
        data(){
            return {
                list: [],
                totalPage: 0,
                page: 1,
                limit: 20,
                statusArr: ["待审核", "商家拒绝", "退款中", "已退款", "用户退货", "商家待收货", "已撤销"]
            }
        },
        methods: {
            sendSold(refundOrderNo){
                this.$emit("sendSold", refundOrderNo)
            },
            getList(userId) {
                const param = {
                    page: this.page,
                    limit: this.limit,
                    userId: userId,
                }
                console.log(param)
                orderListAssistantApi(param).then((res) => {
                    this.list = this.list.concat(res.list)
                    this.totalPage = res.totalPage;
                }).catch((err) => {
                    console.log(err)
                });
            },
            getMore(userId){
                if(this.page>=this.totalPage) return
                this.page ++
                this.getList(userId)
            },
            toDetail(orderNo){
                this.$emit("toDetail", "sold", orderNo)
            }
        }
    }
</script>


<style lang="scss" scoped>
    .orderVue {
        width: 100%;
        padding: 10px;
        .order {
            width: 100%;
            margin-top: 20px;
            .orderTop {
                width: 100%;
                height: 50px;
                background: #F6F9FF;
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 0 20px;
                .state {
                    color: #55D6B8;
                    font-size: 15px;
                }
                .oNo {
                    color: #737374;
                    font-size: 15px;
                }
            }
            .orderBot {
                width: 100%;
                border: 1px solid #f5f5f5;
                border-top: none;
                padding: 20px;
                .infoVue {
                    width: 100%;
                    display: flex;
                    .right {
                        flex: 1;
                        height: 50px;
                        display: flex;
                        flex-direction: column;
                        justify-content: space-between;
                        .flex-between {
                            display: flex;
                            justify-content: space-between;
                            .name {
                                color: #4D4D4D;
                                padding-right: 30px;
                            }
                        }
                    }
                }
                .cell {
                    color: #4D4D4D;
                    padding-top: 15px;
                }
                .opraVue {
                    margin-top: 15px;
                    display: flex;
                    justify-content: flex-end;
                    span {
                        color: #2561EF;
                        font-size: 15px;
                        cursor: pointer;
                    }
                    .line {
                        width: 1px;
                        height: 16px;
                        background: #2561EF;
                        margin: 0 15px;
                    }
                    span:hover {
                        opacity: 0.7;
                    }
                }
            }
        }
    }
</style>